/**
 * Created by jiangtao on 16/5/5.
 */
(function(){
    var me = {};

    me.init = function(){
       this.Swiper();
    };

    me.Swiper = function(){
        var swiper = new Swiper('.swiper-container',{
            onSlideChangeStart:function(swiper){
                var activeIndex = swiper.activeIndex;
                changeActive(activeIndex);
            }
        });
        $('body').on('click','.image-box-nav li',function(){
            var activeIndex = $('.image-box-nav li').index(this);
            swiper.swipeTo(activeIndex);
            changeActive(activeIndex);
        });
        function changeActive(activeIndex){
            $('.image-box-nav li').each(function(index,dom){
                if(activeIndex == index) {
                    $(dom).addClass('active');
                } else {
                    $(dom).removeClass('active');
                }
            });
        };
    };

    me.init();
})();

